<?php
require("../../../e/class/connect.php");
if(!defined('InEmpireCMS')) {
  exit();
}
$myuserid=0;
$myusername='';
$messageNum=0;
$myuserid=(int)getcvar('mluserid');
$mhavelogin=0;
if($myuserid) {
  include("../../../e/class/db_sql.php");
  include("../../../e/class/user.php");
  include("../../../e/data/dbcache/MemberLevel.php");
  $link=db_connect();
  $empire=new mysqlquery();
  $mhavelogin=1;
  //未读消息
  $messageNum = $empire->num('select * from pw_ms_relations where uid = '.$myuserid.' and status = 1');
  //数据
  $myusername=RepPostVar(getcvar('mlusername'));
  $myrnd=RepPostVar(getcvar('mlrnd'));
  $r=$empire->fetch1("select ".$user_userid.",".$user_username.",".$user_group.",".$user_userfen.",".$user_money.",".$user_userdate.",".$user_havemsg.",".$user_checked." from ".$user_tablename." where ".$user_userid."='$myuserid' and ".$user_rnd."='$myrnd' limit 1");
  if(empty($r[$user_userid])||$r[$user_checked]==0) {
    EmptyEcmsCookie();
    $mhavelogin=0;
  }
  //会员等级
  if(empty($r[$user_group])) {
    $groupid=$user_groupid;
  }
  else {
    $groupid=$r[$user_group];
  }
  $groupname=$level_r[$groupid]['groupname'];
  //点数
  $userfen=$r[$user_userfen];
  //余额
  $money=$r[$user_money];
  //天数
  $userdate=0;
  if($r[$user_userdate]) {
    $userdate=$r[$user_userdate]-time();
    if($userdate<=0) {
      $userdate=0;
    }
    else {
      $userdate=round($userdate/(24*3600));
    }
  }
  //是否有短信息
  $havemsg="";
  if($r[$user_havemsg]) {
    $havemsg="<a href='".$public_r['newsurl']."e/member/msg/' target=_blank><font color=red>您有新信息</font></a>";
  }
  //$myusername=$r[$user_username];
  db_close();
  $empire=null;
}
//alert(array(status=>$mhavelogin,info=>array(uid=>$myuserid,username=>$myusername,message_num=>$messageNum)));
echo json_encode(array(status=>$mhavelogin,info=>array(uid=>$myuserid,username=>$myusername,message_num=>$messageNum)));
//if($mhavelogin==1) {
//  echo json_encode(array(status=>1,info=>array(uid=>$myuserid,username=>$myusername,message_num=>$messageNum)));
//}
//else {
//  echo json_encode(array(status=>0,info=>array(uid=>0,username=>'',message_num=>0)));
//}
?>

